<?php

namespace app\api\model\user;

use app\api\model\BaseModel;

class UserAssetsLogModel extends BaseModel
{
    protected $name = 'user_assets_log';
    public const TYPE_REGISTER = 100; //注册送金额
    public const TYPE_INVITATION = 200; //邀请奖励
    public const TYPE_MINING = 300; //购买矿机
    public const TYPE_MINING_PRICE = 400; //矿机收益
    public const TYPE_MINING_REMIT = 500; // 矿机打钱
    public const TYPE_MINING_RECHARGE = 600; // 充值
    public const TYPE_SYSTEM = 700; // 系统操作

    public const TYPE_ARR = [
        self::TYPE_REGISTER => 'Sign up to Send Usdt',
        self::TYPE_INVITATION => 'Invitations and Rewards',
        self::TYPE_MINING => 'Buying mining machine',
        self::TYPE_MINING_PRICE => 'Miner income',
        self::TYPE_MINING_REMIT => 'Miner remit',
        self::TYPE_MINING_RECHARGE => 'recharge',
        self::TYPE_SYSTEM => 'system',
    ];

    /**
     * Notes: 创建资产日志
     * User: 浪子膏
     * Date: 2023/10/21 15:03
     * @param $user_id
     * @param $money
     * @param $type
     * @param $be
     * @param $order_id
     * @return bool
     */
    public function createLog($money_type, $user_id, $money, $type, $be = 1, $order_no = ''): bool
    {
        $later = UserAssetsModel::where('user_id', $user_id)->value($money_type);
        $this->save([
            'user_id' => $user_id,
            'money_type' => $money_type,
            'money' => $money,
            'later' => $later,
            'type' => $type,
            'be' => $be,
            'order_no' => $order_no,
        ]);

        return true;
    }


}